home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / CPPLINIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  6.0 KB  |  145 lines

  1. /*****************************************************************************/
  2. /*       (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved         */
  3. /*****************************************************************************/
  4. /*    This source-code is NOT public domain nor Freeware, this is part of    */
  5. /*              'The C Programming Package' which is Shareware.              */
  6. /*   If you use this code, please register and get a free Full-VGA version   */
  7. /*****************************************************************************/
  8.                             /*----------------*
  9.                              *   CPPLINIT.C   *
  10.                              *  Text Version  *
  11.                              * Initialisation *
  12.                              *----------------*/
  13.  
  14.  /* Included Files */
  15.  # include <stdio.h>
  16.  # include <io.h>
  17.  # include <fcntl.h>
  18.  # include <SYS\stat.h>
  19.  # include <dir.h>
  20.  # include <string.h>
  21.  
  22.  /* Global Variables */
  23.  extern int x,y,z,i,j,k,l,m,n,printer,number,videocard,nbdisk,returning;
  24.  extern int colour1,colour2,colour3,colour4,colour5;
  25.  extern int pfserv,pfhelp,pfdiv;
  26.  extern long dep,dephelp;
  27.  extern unsigned char trashcan[],trashhelp[],trashelhelp[];
  28.  extern unsigned char path[],record[],work[];
  29.  
  30.  
  31.  /*----------------------*
  32.   * READ HARDWARE CONFIG *
  33.   *----------------------*/
  34.   int read_hardware_config()
  35.     {
  36.       /* Read the numbers of drives (hard or floppy) */
  37.       i=biosequip();
  38.       if(i & 64){
  39.         /* At least 3 drives */
  40.     nbdisk=3;
  41.     if(i & 128){
  42.           /* 4 drives */
  43.       nbdisk=4;
  44.     }
  45.       }
  46.       /* Open the service file to get the current colours and to save */
  47.       /* them if required                                             */
  48.       returning=open_working_file();
  49.       if(returning==0)                    return(0);
  50.       dep=lseek(pfserv,0L,SEEK_SET)+4;
  51.       /*++++++++++++++ Colours ++++++++++++++ */
  52.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  53.       trashcan[3]=0x00;                number=atoi(trashcan);
  54.       if(number>0)                     colour1=number;
  55.       dep+=3;
  56.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  57.       trashcan[3]=0x00;                number=atoi(trashcan);
  58.       if(number>0)                     colour2=number;
  59.       dep+=3;
  60.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  61.       trashcan[3]=0x00;                number=atoi(trashcan);
  62.       if(number>0)                     colour3=number;
  63.       dep+=3;
  64.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  65.       trashcan[3]=0x00;                number=atoi(trashcan);
  66.       if(number>0)                     colour4=number;
  67.       dep+=3;
  68.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  69.       trashcan[3]=0x00;                number=atoi(trashcan);
  70.       if(number>0)                     colour5=number;
  71.       dep+=18;
  72.       /*++++++++++++++ printer type ++++++++++++++*/
  73.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  74.       trashcan[3]=0x00;                printer=atoi(trashcan);
  75.       /*++++++++ Get the videocard type choosen +++++++++++*/
  76.       /* by the user and this is not necessary the best one */
  77.       dep+=3;
  78.       lseek(pfserv,dep,0);             read(pfserv,trashcan,3);
  79.       trashcan[3]=0x00;                videocard=atoi(trashcan);
  80.       /*+++++++++++  Get the choosen path to the  +++++++++++++++*/
  81.                /* data files, as choosen by the user */
  82.       dep+=3;
  83.       lseek(pfserv,dep,0);             read(pfserv,path,64);
  84.       path[64]=0x00;
  85.       /* Check it to see if it is the directory where we are */
  86.       /* if not, we ask to change it */
  87.       getcwd(trashcan,80);             trashcan[64]=0x00;
  88.       j=strcmpi(path,trashcan);
  89.       if(j!=0){
  90.         k=message(" Current directory"," different of"," the saved one"," Modify ?"," Y/N ?");
  91.         if(k==34){
  92.           /* Answer = YES we copy the new path as the active one */
  93.           strcpy(path,trashcan);
  94.           lseek(pfserv,dep,0);         write(pfserv,path,64);
  95.     }
  96.       }
  97.       /*++++++ Recording path ++++*/
  98.       dep+=64;
  99.       lseek(pfserv,dep,0);             read(pfserv,record,64);
  100.       record[64]=0x00;
  101.       /*++++++ Working path ++++*/
  102.       dep+=64;
  103.       lseek(pfserv,dep,0);             read(pfserv,work,64);
  104.       work[64]=0x00;
  105.        /* We check it to see if it is the directory where we are */
  106.       /* if not we ask to change it */
  107.       getcwd(trashcan,80);             trashcan[64]=0x00;
  108.       j=strcmpi(work,trashcan);
  109.       if(j!=0){
  110.         k=message(" Current work"," directory"," different of"," the saved one"," Modify ? Y/N");
  111.         if(k==34){
  112.          /* Answer = YES we copy the new path as the active one */
  113.           strcpy(work,trashcan);
  114.           lseek(pfserv,dep,0);         write(pfserv,work,64);
  115.     }
  116.       }
  117.       /*++++++++++++++ close the file ++++++++++++++*/
  118.       if(pfserv>-1)                    close(pfserv);
  119.       pfserv=-1;                       return(1);
  120.     }
  121.  /*--------------*
  122.   * INIT COLOURS *
  123.   *--------------*/
  124.   void init_colour()
  125.     {
  126.       /* VideoCard detection : colour or monochrome                          */
  127.       /* ATTENTION if the card is a colour one and the monitor is monochrome */
  128.       /* You need to change yourself the program : we detect the card        */
  129.       k=biosequip();
  130.       /* If the service file was erased we init the colours */
  131.       if((k & 48)==32){
  132.         /* Mode 80x25 colour (videocard) */
  133.         colour1=30;                   /* 14+1*16 = Yellow over Blue    */
  134.         colour2=112;                  /* 0+7*16  = Black over Lightgrey*/
  135.         colour3=15;                   /* 15+0*16 = White over Black    */
  136.         colour4=32;                   /* 0+2*16  = Black over Green    */
  137.         colour5=78;                   /* 14+4*16 = Yellow over Red     */
  138.       }
  139.       else{
  140.         colour1=112;        colour2=15;        colour3=15;
  141.         colour4=15;         colour5=143;
  142.       }
  143.     }
  144. /* End of supplement of main program  */
  145.